var windowName = "userDown";
var Page
apiready = function(){
    onWindowShow(function () {
    })
    onWindowHide(function () {
    })
    var dl = new DownLoad()
    console.log("index page is OK");
    Page = createVM("#Page",{
        //页面数据
        dl:{}
        ,showDel:false
    },{
        //页面方法
        "init":function () {
            dl.getData(function (data) {
                console.log(data);
                Page.dl = data
                logJson(data)
            })
            setInterval(function () {
                dl.getData(function (data) {
                    console.log(data);
                    Page.dl = data
                    logJson(data)
                })
            },2000)

        }
        ,showManager:function () {
            this.showDel?this.showDel=false:this.showDel=true;
        }
        ,play:function (title,url) {
            var videoPlayer = api.require('videoPlayer');
            videoPlayer.play({
                texts: {
                    head: {
                        title: title
                    }
                },
                styles: {
                    head: {
                        bg: 'rgba(0.5,0.5,0.5,0.7)',
                        height: 30,
                        titleSize: 20,
                        titleColor: '#fff',
                        backSize: 24,
                        backImg: 'fs://img/back.png',
                        setSize: 0,
                        setImg: 'fs://img/set.png'
                    },
                    foot: {
                        bg: 'rgba(0.5,0.5,0.5,0.7)',
                        height: 30,
                        playSize: 24,
                        playImg: 'fs://img/back.png',
                        pauseImg: 'fs://img/back.png',
                        nextSize: 0,
                        nextImg: 'fs://img/back.png',
                        timeSize: 14,
                        timeColor: '#fff',
                        sliderImg: 'fs://img/slder.png',
                        progressColor: '#696969',
                        progressSelected: '#76EE00'
                    }
                },
                path: url, //（可选项）字符串类型；文档的路径，支持网络和本地（fs://）路径；默认：未传值时不播放
                //在 android 平台上不支持 widget://
                autoPlay: true //（可选项）布尔类型；打开时是否自动播放；默认：true（自动播放）
                ,autorotation:false
            }, function(ret, err) {
                if (ret) {
                    log(JSON.stringify(ret));
                } else {
                    log(JSON.stringify(err));
                }
            });
        }
        ,del:function (id) {
            dl.del(id)
            Page.dl = dl.getList();
        }
    })
    Page.init()
}
